from ..extensions import db
from .base import BaseModel

class ParkingApron(BaseModel):
    """停机坪信息模型"""
    __tablename__ = 'ParkingAprons'
    
    id = db.Column(db.Integer, primary_key=True)
    airport_id = db.Column(db.Integer, db.ForeignKey('Airports.id'), nullable=False)
    type = db.Column(db.String(50), nullable=False)
    name = db.Column(db.String(100), nullable=False)
    net_depth = db.Column(db.Float, nullable=False)
    width = db.Column(db.Float, nullable=False)
    parking_method = db.Column(db.String(50), nullable=False)
    quantity = db.Column(db.Integer, nullable=False)
    
    def to_dict(self):
        return {
            'id': self.id,
            'airport_id': self.airport_id,
            'type': self.type,
            'name': self.name,
            'net_depth': self.net_depth,
            'width': self.width,
            'parking_method': self.parking_method,
            'quantity': self.quantity,
            'created_at': self.created_at.isoformat(),
            'updated_at': self.updated_at.isoformat()
        } 